<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8" />
  <title>03_人员案例-comptude实现.html</title>
  <!-- 引入Vue -->
  <script type="text/javascript" src="../js/vue.js"></script>
</head>

<body>
  <!-- 准备好一个容器-->
  <div id="demo">
    <h1>人员案例练习</h1>
    搜索:<input type="text" v-model="keyword"><br>
    <ul>
      <li v-for="(item,index) in SearchName">{{item.name}}-{{item.age}}-{{item.gender}}</li>
    </ul>
  </div>
</body>

<script type="text/javascript">
  //阻止 vue 在启动时生成生产提示。
  Vue.config.productionTip = false;
  new Vue({
    el: '#demo',
    data: {
      keyword: '',
      persons: [
        { id: "wfsafsfgs01", name: '马冬梅', age: 18, gender: '女' },
        { id: "wfsafsfgs02", name: '周冬雨', age: 19, gender: '女' },
        { id: "wfsafsfgs03", name: '周杰伦', age: 20, gender: '男' },
        { id: "wfsafsfgs04", name: '文灶轮', age: 21, gender: '男' },
      ],
    },
    computed: {
      SearchName() {
        return this.persons.filter((item) => {
          return item.name.includes(this.keyword)
        })
      }
    }
  })
</script>

</html>